package br.unicamp.ic.sgct.server.dominio.entidades;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import br.unicamp.ic.sgct.client.dominio.to.StandTO;

//import it.biobytes.ammentos.AutomaticType;
//import it.biobytes.ammentos.PersistentEntity;
//import it.biobytes.ammentos.PersistentField;

@SuppressWarnings("serial")
//@PersistentEntity(sourceDomain = "T_STAND", primaryKey = "id_stand")
@Entity
@Table(name="T_STAND")
@TableGenerator(name = "STAND_GEN", allocationSize = 1, initialValue = 1, table = "T_ID", 
		pkColumnName = "key", valueColumnName = "valor", pkColumnValue = "ID_STAND")
public class Stand implements Serializable {
	//@PersistentField(fieldName="id_stand", automatic=true, automaticType=AutomaticType.FRAMEWORK)
	@Id
	@Column(name="id_stand")
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "STAND_GEN")
	private long id;

	//@PersistentField
	@Column
	private int numero;

	//@PersistentField
	@Column
	private int metragem;

        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "id_cconv", nullable = false)
	private CentroConvencao centroConvencao;

	public Stand() {
		super();
	}

	public Stand(int numero, int metragem) {
		super();
		this.numero = numero;
		this.metragem = metragem;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getNumero() {
		return numero;
	}

	public void setNumero(int numero) {
		this.numero = numero;
	}

	public int getMetragem() {
		return metragem;
	}

	public void setMetragem(int metragem) {
		this.metragem = metragem;
	}

	/**
	 * Constructs a <code>String</code> with all attributes
	 * in name = value format.
	 *
	 * @return a <code>String</code> representation 
	 * of this object.
	 */
	public String toString()
	{
	    final String TAB = "    ";
	    
	    String retValue = "";
	    
	    retValue = "Stand ( "
	        + super.toString() + TAB
	        + "id = " + this.id + TAB
	        + "numero = " + this.numero + TAB
	        + "metragem = " + this.metragem + TAB
	        + " )";
	
	    return retValue;
	}
	
	
	public StandTO getTo(){
		StandTO to = new StandTO();
		to.setId(id);
		to.setMetragem(metragem);
		to.setNumero(numero);
		return to;
	}
}